package cn.zhb.backend.controller;

import cn.zhb.backend.core.dto.UserSaveDto;
import cn.zhb.backend.service.UserService;
import cn.zhb.backend.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/***
 *@Description
 *@Author ZHB
 *@Create 2025/7/3 下午11:14
 **/
@RestController
@RequestMapping("/user")
@Api("用户管理")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation("用户登录")
    @GetMapping("/login")
    public Result login(
            @ApiParam(name = "account", value = "账号", required = true)
            @RequestParam String account,
            @ApiParam(name = "password",value = "密码", required = true)
            @RequestParam String password) {
        return Result.success(userService.login(account, password));
    }

    @ApiOperation("注册")
    @PostMapping("/register")
    public Result register(@RequestBody UserSaveDto userSaveDto) {
        return Result.success(userService.register(userSaveDto));
    }

}
